﻿using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using WebWap.Handler;
using WebWap.Models;

namespace WebWap.Controllers
{
    /// <summary>
    /// 模拟数据来源
    /// </summary>
    public class DataController : BaseController
    {
        /// <summary>
        /// 主页
        /// </summary>
        public IActionResult Index()
        {
            ViewBag.Title = "主页";
            return View();
        }

        public IActionResult Test()
        {
            ViewBag.Title = "测试";
            return View();
        }

        public IActionResult Test2()
        {
            ViewBag.Title = "测试2";
            return View();
        }

        /// <summary>
        /// 列表数据
        /// </summary>
        [HttpGet]
        [AjaxOnly]
        public ActionResult GetData(int id)
        {
            List<Goods> data = new List<Goods>();
            var ls = Enumerable.Range(1, id * 10);
            foreach (var v in ls)
                data.Add(new Goods { Id = v, Name = "Sku" + v, Url = "XXX" });

            return this.SuccessJson(data);
        }
    }
}